*REPLICATION CODE FOR "Licensing Life-Saving Drugs for Developing Countries: Evidence from the Medicines Patent Pool" Tables 1-3

u country_drugs.dta, clear


*generate panel identifier*
gen id = product+country
encode id, gen(ID)
drop id


gen MPP_sublicense= MPP_down
replace MPP_sublicense=. if access==0
gen Bilateral_deal= bilateral
replace Bilateral_deal=. if access==0
gen Deals= deals
replace Deals=. if access==0

***********************
*TABLE 1 - PANEL A ****
***********************
eststo clear
estpost summ access Deals MPP_sublicense Bilateral_deal 
esttab, cells("count mean sd min max") replace
drop Deals MPP_sublicense Bilateral_deal 
 

*************************
*TABLE 1 - PANEL B  *****
*************************

*1st line
summ access if ever_MPP==0 
summ deals if ever_MPP==0 

*2nd line
summ access if ever_MPP==1 & MPP==0 
summ deals if ever_MPP==1 & MPP==0 

*3rd line
summ access if ever_MPP==1 & MPP==1 
summ deals if ever_MPP==1 & MPP==1 


***********
*TABLE 2 **
***********

encode product, gen(product_code)
encode country, gen(country_code)

xtset ID year

eststo clear
qui: eststo: reghdfe access MPP, a(ID year) vce(cluster product_code country_code)
qui: eststo: reghdfe deals MPP, a(ID year) vce(cluster product_code country_code)
qui: eststo: reghdfe access MPP if priority_list==1 , a(ID year) vce(cluster product_code country_code)
qui: eststo: reghdfe deals MPP if priority_list==1 , a(ID year) vce(cluster product_code country_code)
qui: eststo: reghdfe access MPP, a(ID i.year#i.country_code i.year#i.product_code) vce(cluster product_code country_code)
qui: eststo: reghdfe deals MPP, a(ID i.year#i.country_code i.year#i.product_code) vce(cluster product_code country_code)
esttab,  b(3) se(3) star(* 0.10 ** 0.05 *** 0.01)  keep(MPP*) replace 



merge n:1 country year using WB_status
drop _m
merge n:1 country year using HIV_pop
drop _m


cap drop topHIV
gen topHIV=0
replace topHIV=1 if hiv_living>940000

gen MPP_high_disease_prev=MPP*topHIV

cap drop H
gen H=0
replace H=1 if status~="L"

gen HH=topHIV*H

gen MPP_high_disease_prev_middle=MPP*topHIV*H

*******************************
*TABLE 3 - first three columns*
*******************************

eststo clear 
qui: eststo: reghdfe access MPP MPP_high_disease_prev topHIV  if disease=="HIV" & hiv_living<., absorb(year ID) vce(cluster product_code country_code)
qui: eststo: reghdfe access MPP MPP_high_disease_prev MPP_high_disease_prev_middle topHIV H HH if disease=="HIV" & hiv_living<., absorb(year ID) vce(cluster product_code country_code)
qui: eststo: reghdfe access MPP MPP_high_disease_prev MPP_high_disease_prev_middle topHIV H HH if disease=="HIV" & hiv_living<. & priority_list==1, absorb(year ID) vce(cluster product_code country_code)
esttab,  b(3) se(3) star(* 0.10 ** 0.05 *** 0.01)  keep(MPP*) replace 


merge n:1 country year using WB_TB.dta
drop _m

gen top90=topHIV
gen TB_living= incidenceoftuberculosisper100000*pop_tot/100000
replace top90=0 if disease=="TB"
replace top90=1 if TB_living> 466953 & disease=="TB"
replace HH=0 if disease=="TB"
replace HH=1 if H==1 & top90==1 & disease=="TB"

merge n:1 country using "HepC2015.dta"
drop _m

replace top90=0 if disease=="H-C"
replace top90=1 if HepC> 6245 & disease=="H-C"
replace HH=0 if disease=="H-C"
replace HH=1 if H==1 & top90==1 & disease=="H-C"

drop MPP_high_disease_prev
gen MPP_high_disease_prev=MPP*top90

drop MPP_high_disease_prev_middle
gen MPP_high_disease_prev_middle=MPP*top90*H

**********************
*TABLE 3- last column*
**********************
eststo clear
qui: eststo: reghdfe access MPP MPP_high_disease_prev MPP_high_disease_prev_middle top90 H HH if (disease=="HIV" | disease=="TB" | disease=="H-C") & (hiv_living<. | TB_living<. | HepC<.), absorb(year ID) vce(cluster product_code country_code)
esttab,  b(3) se(3) star(* 0.10 ** 0.05 *** 0.01)  keep(MPP*) replace

